<template>
	<view>
		<u-tabbar height="110rpx" icon-size="45" active-color="#354678" inactive-color="#777777" v-model="current"
			:list="list"></u-tabbar>
	</view>
</template>

<script setup lang="ts">
	import { ref, toRefs } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	import tools from '@/utils/tools'

	const props = defineProps({
		current: {
			type: Number,
			default() {
				return 0
			}
		}
	})

	let current = ref(0)
	current.value = toRefs(props).current.value

	let list = [
		{
			pagePath: '/pages/home/index',
			iconPath: '/static/tabbar/home.png',
			selectedIconPath: '/static/tabbar/home-active.png',
			text: '首页'
		},
		{
			pagePath: '/pages/mine/index',
			iconPath: '/static/tabbar/mine.png',
			selectedIconPath: '/static/tabbar/mine-active.png',
			text: '我的'
		}
	]

	onLoad(() => {
		uni.getSystemInfo({
			success: (res) => {
				tools.setStorage<string>('tabbarHeight', '110rpx')
				tools.setStorage<number>('safeArea', res.screenHeight - res.safeArea.bottom)
			},
			fail(err) {
				console.log(err)
			}
		})
	})
</script>

<style lang="scss" scoped></style>